package com.ruoyi.uav.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.mapper.SysUserMapper;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.uav.mapper.UavTeachingMaterialMapper;
import com.ruoyi.uav.domain.UavTeachingMaterial;
import com.ruoyi.uav.service.IUavTeachingMaterialService;

import javax.annotation.Resource;

/**
 * 教材信息Service业务层处理
 *
 * @author ruoyi
 * @date 2024-01-04
 */
@Service
public class UavTeachingMaterialServiceImpl extends ServiceImpl<UavTeachingMaterialMapper, UavTeachingMaterial> implements IUavTeachingMaterialService {
    @Resource
    private UavTeachingMaterialMapper uavTeachingMaterialMapper;


    /**
     * 查询教材信息列表
     *
     * @param uavTeachingMaterial 教材信息
     * @return 教材信息
     */
    @Override
    public List<UavTeachingMaterial> selectUavTeachingMaterialList(UavTeachingMaterial uavTeachingMaterial) {
        List<String> roles  = uavTeachingMaterialMapper.selectUserRoles(SecurityUtils.getUserId());
        if (ObjectUtils.isNotEmpty(roles)){
            boolean b = roles.stream().noneMatch("student"::equals);
            if (!b){
                uavTeachingMaterial.setPermission("1");
            }
        }
        return uavTeachingMaterialMapper.selectUavTeachingMaterialList(uavTeachingMaterial);
    }

}
